package com.xiaolin.designmode.visitor;

import com.sun.org.apache.bcel.internal.generic.NEW;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * @ClassName ObjectStructure
 * @Description 对象解构角色
 * @Detail detail
 * @Author MyPC
 * @Date 2020/11/8
 * @Version 1.0
 */
public class ObjectStructure {
    private List<Element> list=new ArrayList<>();
    public void add(Element element){
        list.add(element);
    }
    public void remove(Element element){
        list.remove(element);
    }
    public void accept(Visitor visitor){
        Iterator<Element> iterator = list.iterator();
        while (iterator.hasNext()){
            iterator.next().accept(visitor);
        }
    }
}
